<template>
    <j-modal :title="title" :width="width" :visible="visible" switchFullscreen @ok="handleOk" @cancel="handleCancel"
        cancelText="关闭">
        <a-form-model ref="form" :model="model" :rules="rules">
            <a-row>
                <a-col :span="24">
                    <a-form-model-item label="自动储值金额" :labelCol="labelCol" :wrapperCol="wrapperCol"
                        prop="mealSupplement">
                        <a-input v-model="model.mealSupplement" placeholder="请输入数量"></a-input>
                    </a-form-model-item>
                </a-col>
            </a-row>
            <!-- <a-row>
                <a-col :span="24">
                    <a-form-model-item label="所属公司" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="companyId">
                        <j-dict-select-tag v-model="model.companyId"
                            dict-code="HC_COMPANY_INFO,COMPANY_NAME,ID,DEL_FLAG=0" placeholder="请选择所属公司"
                            style="flex:1" />
                    </a-form-model-item>
                </a-col>
            </a-row> -->
        </a-form-model>
    </j-modal>
</template>

<script>
import { getAction, postAction } from '@api/manage'
export default {
    data() {
        return {
            labelCol: {
                xs: { span: 24 },
                sm: { span: 5 },
            },
            wrapperCol: {
                xs: { span: 24 },
                sm: { span: 16 },
            },
            title: '设置储值金额',
            width: 800,
            visible: false,
            model: {},
            rules: {
                mealSupplement: [
                    { required: true, message: '请输入自动储值金额!' },
                ],
                companyId: [
                    { required: true, message: '请选择公司!' },
                ],
            },
        }
    },
    methods: {
        show(id) {
            this.model.id = id;
            this.visible = true;
        },
        handleOk() {
            this.$refs.form.validate(async valid => {
                if (valid) {
                    console.log('this.model', this.model);
                    let res = await postAction('/hc/hcCompanyInfo/setCompanyMealSupplement', this.model);
                    console.log('res', res);
                    if (res.success) {
                        this.$message.success('设置成功');
                        this.handleCancel();
                        this.$emit('loadData')
                    } else {
                        this.$message.warning(res.message);
                    }
                }
            })
        },
        handleCancel() {
            this.model.mealSupplement = null;
            this.visible = false
        }
    }
}
</script>